package 分类算法总的很好.剑指offer;
import java.util.*;

// https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=23278&ru=/ta/sql-quick-study&qru=/ta/sql-quick-study/question-ranking
public class JZ3从尾到头打印链表1002 {

        public class ListNode {
            int val;
            ListNode next = null;

            ListNode(int val) {
                this.val = val;
            }
        }

    public class Solution {
        public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
            ArrayList<Integer> list = new ArrayList<>();
            ListNode tmp = listNode;
            while(tmp!=null){
                list.add(0,tmp.val);
                tmp = tmp.next;
            }
            return list;
        }
    }
}
